using Lzfy_His_Service.Models;

namespace Lzfy_His_Service.Repositories
{
    /// <summary>
    /// UUM用户仓储接口
    /// </summary>
    public interface IUumUserRepository
    {
        /// <summary>
        /// 根据用户名查询UUM用户信息
        /// </summary>
        /// <param name="userName">用户名</param>
        /// <returns>用户信息</returns>
        Task<UumUser?> GetUserByUserNameAsync(string userName);

        /// <summary>
        /// 根据用户ID查询UUM用户信息
        /// </summary>
        /// <param name="userId">用户ID</param>
        /// <returns>用户信息</returns>
        Task<UumUser?> GetUserByIdAsync(int userId);

        /// <summary>
        /// 根据工号查询UUM用户信息
        /// </summary>
        /// <param name="peopleIdentifier">工号</param>
        /// <returns>用户信息</returns>
        Task<UumUser?> GetUserByPeopleIdentifierAsync(string peopleIdentifier);

        /// <summary>
        /// 检查用户名是否存在
        /// </summary>
        /// <param name="userName">用户名</param>
        /// <returns>是否存在</returns>
        Task<bool> UserNameExistsAsync(string userName);

        /// <summary>
        /// 根据用户名更新用户电话
        /// </summary>
        /// <param name="userName">用户名</param>
        /// <param name="userPhone">用户电话</param>
        /// <returns>是否更新成功</returns>
        Task<bool> UpdateUserPhoneAsync(string userName, string? userPhone);

        /// <summary>
        /// 根据用户名查询用户电话
        /// </summary>
        /// <param name="userName">用户名</param>
        /// <returns>用户电话</returns>
        Task<string?> GetUserPhoneAsync(string userName);

        /// <summary>
        /// 根据用户名更新退费任务数量
        /// </summary>
        /// <param name="userName">用户名</param>
        /// <param name="taskAmount">退费任务数量</param>
        /// <returns>是否更新成功</returns>
        Task<bool> UpdateTaskAmountAsync(string userName, int taskAmount);

        /// <summary>
        /// 根据用户名查询退费任务数量
        /// </summary>
        /// <param name="userName">用户名</param>
        /// <returns>退费任务数量</returns>
        Task<int> GetTaskAmountAsync(string userName);

        /// <summary>
        /// 批量更新授权码：将id_no字段不为空的数据，截取id_no的后四位，加上@再加上user_name，存入auth_code字段
        /// </summary>
        /// <returns>更新结果，包含更新的记录数和总记录数</returns>
        Task<(int UpdatedCount, int TotalCount)> BatchUpdateAuthCodeAsync();
    }
}